import { reqSkuList } from "@/api/product/sku"
// ,reqSale,reqCancel,reqSkuById
const skuStore = {
    state:{
        page:1,
        limit:10,
        total:0,
        recodes:[]
    },
    mutations:{
        SET_SKU_LIST(state,payload){
            state.total = payload.total;
            state.recodes = payload.recodes;
        },
        SET_PAGE(state, page) {
            state.page = page; // 新增一个 mutation 来更新 page
        },
        SET_LIMIT(state, limit) {
            state.limit = limit; // 新增一个 mutation 来更新 limit
        }
    },
    actions:{
        //获取Sku列表数据
        async setSkuList({commit,state},page = 1){
            commit("SET_PAGE",page) // 调用 mutation 来更新 page
            const { limit } = state; // 从 state 中获取 limit
            const res = await reqSkuList({page,limit});
            if(res.code === 200){
                commit("SET_SKU_LIST",{
                    total:res.data.total,
                    recodes:res.data.records
                })
            }
        },
    },
    getters:{}
}
export default skuStore